<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎登陆飞猪旅行网</title>
    <script src="/jquerydemo/script/jquery-3.3.1.js"></script>
    <script>
        // location.href = "http://www.w3school.com.cn/ajax/"
        // location.href = "http://www.baidu.com"

        function logout() {
            $.get({url:"http://localhost:8080/logout", async:true,success:function(resp, status, xhr) {
                // resp = JSON.parse(resp);
                console.log("我是前面的")
                if (resp.code == 200) {
                    location.href = "http://localhost:8080/login";
                }
                }})

            $.get({url:"/jquerydemo/json/epms.json", async:true,
                success:function (resp, status, xhr) {
                    // console.log(status)
                    // console.log(resp)
                    $("#json").text(resp[0])
                    console.log("我是后面的")
                }})
        }

        function getData() {
            $.post({
                url:"http://localhost:8080/logout_03",
                contentType : 'application/json',
                // dataType:"json",
                data: JSON.stringify({username:"张三"}),
                success:function (resp, status, xhr) {
                    // resp = JSON.parse(resp);
                    console.log("我是前面的")
                    if (resp.code == 200) {
                        location.href = "http://localhost:8080/login";
                    }
                }})
        }
    </script>
</head>
<body>
    <input onclick="logout()" type="button" value="退出登录" />

    <div>
        <span id="json"></span><br />
        <span id="tomcat"></span>
    </div>
<button onclick="getData()">获取数据</button>
</body>
</html>